<template>
    <div class="text">
        <div class="login-container" >
          <center>
            <el-card class="login-card">
                <h1 class="login-title">积云商城</h1>
                <el-form ref="loginForm" :model="loginForm"   class="login-form">
                    <el-form-item prop="name">
                        手机号：<el-input v-model="loginForm.name" placeholder="请输入用户名" style="width: 200px" ></el-input>
                    </el-form-item>
                    <el-form-item prop="password">
                        密码：<el-input v-model="loginForm.password" type="password" placeholder="请输入密码" style="width: 200px" ></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="login">登录</el-button>
                    </el-form-item>
                </el-form>
            </el-card>
          </center>
        </div>
    </div>
</template>

<script>
    export default {
        name: "Text",
        data(){
            return{
                loginForm: {
                    name: '',
                    password: ''
                },
                // loginRules: {
                //     username: [
                //         { required: true, message: '请输入用户名', trigger: 'blur' }
                //     ],
                //     password: [
                //         { required: true, message: '请输入密码', trigger: 'blur' }
                //     ]
                // },
                // from:{
                //     id:"",
                //     type:"",
                // }
            }
        },
        methods:{
            login() {
               this.axios.post(`http://localhost:9001/api/member/login`,this.loginForm).then(res=>{
                   if (res.data.code==200){
localStorage.setItem("token",res.data.data);
                     this.$message.success("登陆成功");
              this.$router.push({name:"tes",query:{name:this.loginForm.name}})

                   }else {
                     this.$message.error("登陆失败");
                   }
               })
            }
        },
        created(){

        }
    }
</script>

<style scoped>

</style>
